using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
namespace SuperPolarity
{
- class MainShip
+ class MainShip : Ship
{
- public Texture2D PlayerTexture;
- public Vector2 Position;
- public bool Active;
- public int Lives;
- public int Multiplier;
- public int Score;
- public float Angle;
-
- public int Width
+
+ uint Multiplier;
+ uint Lives;
+ uint Score;
+ ParticleEngine particleEngine;
+
+ public override void Initialize(ContentManager Content, Texture2D texture, Vector2 position)
+ {
+ base.Initialize(Content, texture, position);
+
+ Multiplier = 1;
+ Lives = 3;
+ Score = 0;
+
+ List<Texture2D> texturesList = new List<Texture2D>();
+ texturesList.Add(Content.Load<Texture2D>("Graphics\\circle"));
+ texturesList.Add(Content.Load<Texture2D>("Graphics\\diamond"));
+ texturesList.Add(Content.Load<Texture2D>("Graphics\\star"));
+
+ particleEngine = new ParticleEngine(texturesList, Position);
+
+ BindInput();
+ }
+
+ void BindInput()
{
- get { return PlayerTexture.Width; }
+ InputController.Bind("moveX", HandleHorizontalMovement);
+ InputController.Bind("moveY", HandleVerticalMovement);
}
- public int Height
+ public void HandleHorizontalMovement(float value)
{
- get { return PlayerTexture.Height; }
+ Acceleration.X = value * AccelerationRate;
}
- public void Initialize(Texture2D texture, Vector2 position)
+ public void HandleVerticalMovement(float value)
{
- PlayerTexture = texture;
- Position = position;
- Active = true;
- Multiplier = 1;
- Lives = 3;
- Score = 0;
+ Acceleration.Y = value * AccelerationRate;
}
- public void Update()
+ public override void Update(GameTime gameTime)
{
+ base.Update(gameTime);
+ particleEngine.EmitterLocation = Position;
+ particleEngine.Update();
}
- public void Draw(SpriteBatch spriteBatch)
+ public override void Draw(SpriteBatch spriteBatch)
{
- spriteBatch.Draw(PlayerTexture, Position, null, Color.White, Angle, Vector2.Zero, 1f, SpriteEffects.None, 0f);
+ particleEngine.Draw(spriteBatch);
+ base.Draw(spriteBatch);
}
}
}